package com.example.JavaWebApi.controller.systemController;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.JavaWebApi.core.apiinterceptors.annotation.Authorize;
import com.example.JavaWebApi.model.entity.systemEntity.Roleinfo;
import com.example.JavaWebApi.model.vo.systemVo.IntegerBothBindVo;
import com.example.JavaWebApi.service.systemService.IRoleinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *  前端控制器
 * @author 杨泽
 * @since 2022-06-15
 */
@RestController
@RequestMapping("/api/roleinfo")
@Api(tags ="")
@Authorize
public class RoleinfoController {
 
    @Autowired
    public IRoleinfoService RoleinfoService;
    @GetMapping("GetRoleList")
    @ApiOperation("获取角色列表")
    public IPage<Roleinfo> getRoleList(int page, int limit){
        return RoleinfoService.getRoleList(page,limit);
    }
    @PostMapping("Create")
    @ApiOperation("创建一个角色")
    public boolean create(@RequestBody Roleinfo roleInfo){
        return RoleinfoService.create(roleInfo);
    }
    @PostMapping("Update")
    @ApiOperation("更新角色信息")
    public boolean update(@RequestBody Roleinfo roleInfo){
        return RoleinfoService.update(roleInfo);
    }
    @GetMapping("Delete")
    @ApiOperation("获取角色列表")
    public boolean delete(String roleId){
        return RoleinfoService.delete(roleId);
    }
    @PostMapping("RoleForUser")
    @ApiOperation("为用户授权")
    public boolean roleForUser(@RequestBody IntegerBothBindVo vo){
        return RoleinfoService.roleForUser(vo);
    }
    @PostMapping("CancelRoleForUser")
    @ApiOperation("取消用户授权")
    public boolean cancelRoleForUser(@RequestBody IntegerBothBindVo vo){
        return RoleinfoService.cancelRoleForUser(vo);
    }
    @PostMapping("RoleForMenu")
    @ApiOperation("为角色授予菜单")
    public boolean roleForMenu(@RequestBody IntegerBothBindVo vo){
        return RoleinfoService.roleForMenu(vo);
    }

}
